package com.hk.langchain4j_springboot;


import com.hk.langchain4j_springboot.AiService.ClientService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {

// TODO
//版本1
//    @Autowired
//    private OpenAiChatModel openAiChatModel;
//
//    @RequestMapping("/chat")
//    public String chat(String message) {
//        String result = openAiChatModel.chat(message);
//        return result;
//    }


// TODO
    //版本3

//    @Autowired
//    private ClientService clientService;

//    @RequestMapping("/chat")
//    public String chat(String message) {
//         String result = clientService.chat(message);
//        return result;
//    }

    @Autowired
    private ClientService clientService;

    @RequestMapping(value = "/chat",produces = "text/html;charset=utf-8")
    public Flux<String> chat(String memoryId, String message) {
        Flux<String> result = clientService.chat(memoryId, message);
        return result;
    }


}
